import http from "./http";
//列表
export function listreq(current, pagesize) {
  return http({
    method: 'get',
    url: '/goods/list',
    params: { current, pagesize }
  })
}
//商品分类列表
export function lbreq(category) {
  return http({
    method: 'get',
    url: '/goods/list',
    params: { category }
  })
}
//搜索
export function searchreq(search) {
  return http({
    method: 'get',
    url: '/goods/list',
    params: { search }
  })
}
//热销折扣
export function fifterreq(filter) {
  return http({
    method: 'get',
    url: '/goods/list',
    params: { filter }
  })
}
//商品详情
export function itemreq(id) {
  return http({
    method: 'get',
    url: '/goods/item',
    params: { id }
  })
}
//登录
export function loginreq(username, password) {
  return http({
    method: 'post',
    url: '/users/login',
    data: { username, password }
  })
}
//退出登录
export function outreq(id) {
  return http({
    method: 'get',
    url: '/users/logout',
    params: { id }
  })
}
//获取用户详细信息
export function inforeq(id) {
  return http({
    method: 'get',
    url: '/users/info',
    params: { id }
  })
}

//修改密码
export function rpwdreq(id, oldPassword, newPassword, rNewPassword) {
  return http({
    method: 'post',
    url: '/users/rpwd',
    data: { id, oldPassword, newPassword, rNewPassword }
  })
}
//修改个人资料
export function updatereq(id, age, gender, nickname) {
  return http({
    method: 'post',
    url: '/users/update',
    data: { id, age, gender, nickname }
  })
}
//注册
export function regreq(username, password, rpassword, nickname) {
  return http({
    method: 'post',
    url: '/users/register',
    data: { username, password, rpassword, nickname }
  })
}
//获取购物车列表
export function cartreq(id) {
  return http({
    method: 'get',
    url: '/cart/list',
    params: { id }
  })
}
//加入购物车
export function addreq(id, goodsId) {
  return http({
    method: 'post',
    url: '/cart/add',
    data: { id, goodsId }
  })
}
//分类列表
export function categoryreq() {
  return http({
    method: 'get',
    url: '/goods/category',
  })
}
//修改一条商品选中状态
export function adioreq(id, goodsId) {
  return http({
    method: 'post',
    url: '/cart/select',
    data: { id, goodsId }
  })
}
//修改商品数量
export function numreq(id, goodsId, number) {
  return http({
    method: 'post',
    url: '/cart/number',
    data: { id, goodsId, number }
  })
}
//修改全部商品选中状态
export function allradioreq(id, type) {
  return http({
    method: 'post',
    url: '/cart/select/all',
    data: { id, type }
  })
}
//删除一条商品
export function removereq(id, goodsId) {
  return http({
    method: 'get',
    url: '/cart/remove',
    params: { id, goodsId }
  })
}
//支付

export function payreq(id) {
  return http({
    method: 'post',
    url: 'cart/pay',
    data: { id }
  })
}